﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace Adaptive.Log
{
    /// <summary>
    /// Marks a method on a log interface as a method that appends new entry to log/trace.
    /// </summary>
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
    public class LogWriteAttribute : Attribute
    {
        /// <summary>
        /// The id associated with log entry.
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// The message of the log entry. Can include tags like '{0}' to insert method parameters.
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// Severity of entry. Default is Information.
        /// </summary>
        public TraceEventType Severity { get; set; }

        /// <summary>
        /// Marks a method on a log interface as a method that appends new entry to log/trace.
        /// </summary>
        public LogWriteAttribute()
        {
            Severity = TraceEventType.Information;
        }

        /// <summary>
        /// Marks a method on a log interface as a method that appends new entry to log/trace.
        /// </summary>
        /// <param name="id">Id of event.</param>
        /// <param name="message">Message format, parameters can be included using {0}, {1} etc.</param>
        /// <param name="severity">Entry severity.</param>
        public LogWriteAttribute(int id, string message, TraceEventType severity)
        {
            Id = id;
            Message = message;
            Severity = severity;
        }
    }
}
